<!--
	Author: W3layouts
	Author URL: http://w3layouts.com
	License: Creative Commons Attribution 3.0 Unported
	License URL: http://creativecommons.org/licenses/by/3.0/
-->
<!DOCTYPE html>
<html lang="en">
<head>
	<!-- Meta tags -->
	<title>Winter Login Form a Simple Login form Responsive Widget :: w3layouts</title>
	<meta name="keywords" content="Winter Login Form Responsive widget, Flat Web Templates, Android Compatible web template,
	Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- stylesheets -->
	<link rel="stylesheet" href="css/font-awesome.css">
	<link rel="stylesheet" href="css1/style2.css">
	<!-- google fonts  -->
	<link href="//fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
	<link href="//fonts.googleapis.com/css?family=Raleway:400,500,600,700" rel="stylesheet">
	<!-- 2. jQuery导入，建议使用1.9以上的版本 -->
	<script src="js/jquery-3.1.1.min.js"></script>
	<script type="text/javascript"></script>
	<script>
		  // 核心业务逻辑
		  $(function(){
			  $("#submit").click(function(){
				  var username = $("#user").val();
				  var password = $("#password").val();

				  if(username.trim() == "" || password.trim() == "") {
					  alert("用户名或者密码不能为空！");
					  return;
				  }

				  $.ajax({
					  url:"/user/login",
					  data:{"username":username,"password":password},
					  type:"POST",
					  dataType:"json",
					  success:function(data) {
						  console.log(data);
						  if(data.status == 1) {
							  alert("登录成功！");
							  //跳转到指定的页面了
							  window.location.href="musiclist.html";
						  }else{
							alert("登录失败，密码或者用户名错误！");
							$("#user").val("");
							$("#password").val("");
						  }
					  }
				  });
			  });
		  });
	  </script>
</head>
<body>
	<div class="agile-login">
		<h1>Music library</h1>
		<div class="wrapper">
			<h2>Sign In</h2>
			<div class="w3ls-form">
<!--				<form action="/" method="post">-->
					<label>Username</label>
					<input id="user" type="text" autocomplete="false" name="name" placeholder="Username" required/>
					<label>Password</label>
					<input id="password" type="text" autocomplete="false" name="password" placeholder="Password" required />
					<input id="submit" type="submit" value="Log In" />
<!--				</form>-->
			</div>
			
			<div class="agile-icons">
				<a href="#"><span class="fa fa-twitter" aria-hidden="true"></span></a>
				<a href="#"><span class="fa fa-facebook"></span></a>
				<a href="#"><span class="fa fa-pinterest-p"></span></a>
			</div>
		</div>
	</div>
	</div>
	
</body>
</html>